package com.starblink.brand.adapter

import android.graphics.drawable.RotateDrawable
import androidx.core.content.ContextCompat
import com.starblink.android.basic.adapter.BaseBindingVH
import com.starblink.basic.style.R
import com.starblink.brand.bean.FilterCategoryBean
import com.starblink.brand.databinding.CellFilterCategoryBinding
import com.starblink.brand.ui.FilterCategoryI

class FilterCategoryCell (binding: CellFilterCategoryBinding, var filterDialogI: FilterCategoryI?=null) :
    BaseBindingVH<FilterCategoryBean, CellFilterCategoryBinding>(binding) {

    override fun onBind(model: FilterCategoryBean, position: Int) {
        binding.tvCategoryName.text=model.categoryF?.name
        if(model.ifChecked){
            binding.tvCategoryName.icon= RotateDrawable().apply {
                drawable = ContextCompat.getDrawable(
                    itemView.context,
                    R.drawable.ic_svg_checked
                )
            }
        }else{
            binding.tvCategoryName.icon= RotateDrawable().apply {
                drawable = ContextCompat.getDrawable(
                    itemView.context,
                    R.drawable.ic_svg_checkun
                )
            }
        }
        binding.tvCategoryName.setOnClickListener {
            model.ifChecked=!model.ifChecked
            filterDialogI?.changeBtnStates()
        }
    }
}